#include<iostream>
#include<functional>
#include<utility>
using namespace std;

void fun(int& n1, int& n2)
{
	cout<< "In f2, [n1, n2] = [" << n1 << ", " << n2 << "]" <<endl;
}


int main(void)
{
	int x = 10, y = 20;
	
	/* 立即绑定的值，是采用值拷贝，即使参数的类型是引用； 而使用placeholder绑定的值，才能实现延迟绑定 */ 
	auto f = bind(fun, x, y);
	auto g = bind(fun, x, placeholders::_1);
	
	//或者用std::ref，显示指明传递引用过去 
	auto h = bind(fun, x, std::ref(y));
	
	x++;
	y++;
	f();
	g(y);
	h(); 
	
	return 0;
}
